<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title></title>
    <script src="js/mui.min.js"></script>
    <link href="css/mui.min.css" rel="stylesheet"/>
    <link href="css/style.css" rel="stylesheet"/>
    <script type="text/javascript" src="./js/common.js"></script>
</head>
<body>
<div>
    <div class="mui-content mui-scroll-wrapper" id="refreshContainer">
        <div class="mui-scroll">
            <div class="bg-dark mui-text-center pdt-5 pdb-5 pos-relative logo-content">
                <a href="./index.html" class="bg-dark flex flex-jc-around pdt-10 pd-10 pos-relative" style="z-index: 1000;">
                    <img src="./img/arbicap_logo.png" style="height: 80px" alt="">
                    <h1 style="height: 80px;line-height: 80px;" class="cl-white">阿尔卑斯</h1>
                </a>
            </div>
            <ul class="mui-table-view team">
                <li class="mui-table-view-cell flex flex-jc-between">
					<!-- 我的团队 -->
				</li>
            </ul>
        </div>
    </div>
</div>
<script>
	mui('.logo-content').on('click','div',function(){
		location.href = './index.html'
	})
	
    mui('.mui-scroll-wrapper').scroll({
        deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
    });
    mui.init({
        pullRefresh: {
            container: '#refreshContainer',//待刷新区域标识，querySelector能定位的css选择器均可，比如：id、.class等
            up: {
                height: 50,//可选.默认50.触发上拉加载拖动距离
                auto: false,//可选,默认false.自动上拉加载一次
                contentrefresh: "正在加载...",//可选，正在加载状态时，上拉加载控件上显示的标题内容
                contentnomore: '没有更多数据了',//可选，请求完毕若没有更多数据时显示的提醒内容；
                callback: function () {
					page++
                }
            }
        }
    });
	const id = localStorage.getItem('MEMBERS')
	let page = 1
	mui.ajax(HOST + 'v1/members-my-invite', {
		data: {
			page: page,
			members_id: id
		},
		type: 'get', //HTTP请求类型
		timeout: 10000, //超时时间设置为10秒；
		success: function(res) {
			//服务器返回响应，根据响应结果，分析是否登录成功；
			if (res.result === 0) {
				const data = res.data.list
				let html = ''
				if (page === 1) {
					html = ''
				} else {
					html = mui('.team')[0].innerHTML
				}
				let totalPage = res.data.pages.totalPage
				if (page >= totalPage) {
					mui('#refreshContainer').pullRefresh().endPullupToRefresh(true);
				}
				if(data.length>0){
					data.forEach((item) => {
						html +=
							`
					<li class="mui-table-view-cell">
						<p class="m100">名字： ${item.name}</p>
						<p class="m100">账户： ${item.account}</p>
						<p class="m100">注册时间： ${item.reg_date}</p>
					</li>
					`
					})
				}
				mui('.team')[0].innerHTML = html
			} else {
				mui.toast(res.message, {
					duration: 'long',
					type: 'div'
				})
			}
		},
		error: function(xhr, type, errorThrown) {
			mui.toast(errorThrown, {
				duration: 'long',
				type: 'div'
			})
		}
	});
</script>
</body>
</html>
